<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>广告位</title>
    <link href="../../css/admin/style.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-1.8.3.min.js" type="text/javascript"></script >
    <script>
        $(function (){
            $.get("../../newstype/getnewtpyeList",function (res){
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                }else if (res.code == 201){
                    alert(res.msg);
                }else {
                    var str="";
                    for (let i = 0; i < res.data.length; i++) {
                        str += "<tr align='center'>";
                        str+="<td>"+res.data[i].id+"</td>";
                        str+="<td>"+res.data[i].journame+"</td>";
                        str+="<td>"+res.data[i].admin.account+"</td>";
                        str+="<td>"+ (new Date(res.data[i].opertime).toLocaleString())+"</td>";
                        str+="<td><a href='javaScript:void(0)' onclick='toupdate("+res.data[i].id+")' class='tablelink'>修改</a> "
                        str+="<a href='javaScript:void(0)' onclick='todelete("+res.data[i].id+")' class='tablelink'>删除</a> </td>"
                        str+="</tr>";
                    }
                    $("#tableId").append(str);
                }
            },"json")
        })

        function toadd(){
            location.assign("add.html");
        }

        function toupdate(id){
            location.assign("update.html?id="+id);
        }

        function todelete(id){
            $.get("../../newstype/deletenewtpye",{id:id},function (res){
                if (res.code == 202){
                    window.parent.location.replace("../login.html");
                }else if (res.code == 500){
                    alert(res.msg);
                }else {
                    alert(res.msg);
                    location.reload();
                }
            })
        }
    </script>

</head>
<body>
<div class="rightinfo">
    <!-- 顶部按钮 -->
    <div class="tools">
        <ul class="toolbar">
            <a href="javaScript:void(0)" onclick="toadd()">
                <li class="click">
                    <span><img src="../../img/admin/t01.png"/></span>
                    添加
                </li>
            </a>
        </ul>
    </div>

    <!--数据列表 -->
    <table class="tablelist" id="tableId">
        <tr>
            <th >ID</th>
            <th >新闻类型</th>
            <th >操作人</th>
            <th >操作时间</th>
            <th>操作</th>
        </tr>

    </table>
</div>
</body>
</html>